package com.sg.business.projectgroup.editor;

import org.eclipse.jface.viewers.IInputProvider;
import org.eclipse.jface.viewers.IStructuredSelection;

import com.mobnut.db.model.ModelService;
import com.sg.business.model.ProjectGroup;
import com.sg.widgets.part.CurrentAccountContext;
import com.sg.widgets.part.editor.DataObjectWizard;
import com.sg.widgets.viewer.ICreateEditorDelegator;
import com.sg.widgets.viewer.ViewerControl;

public class CreateProjectGroup implements ICreateEditorDelegator {

	@Override
	public IInputProvider create(IStructuredSelection selection,
			String editorId, ViewerControl viewerControl) throws Exception {
		ProjectGroup po = ModelService.createModelObject(ProjectGroup.class);
		po = po.makeDefaultValue(new CurrentAccountContext());
		po.addEventListener(viewerControl);
		DataObjectWizard w = DataObjectWizard.open(po, editorId, true, null);
		po.removeEventListener(viewerControl);
		return w;
	}

}
